Repository navigation
Conversation
Publish complete PAL generations atomically so concurrent initialization and shutdown cannot race provider ownership or close a newer logging stream. Release providers outside the state lock and roll back failed initialization. Files: lib/pal/PAL.cpp, lib/pal/PAL.hpp, tests/functests/BasicFuncTests.cpp, tests/no-exceptions/no-exceptions-smoke.cpp, tests/unittests/PalTests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7e2f450-c2c4-43c5-9fb1-05fa4f7d8e9e
|
CI note: the Ubuntu runner-contract and GCC/Clang public-header failures also occur on unchanged |
Reject allocation-size overflow and preserve full-width multiplication so the bundled allocator cannot silently allocate less than requested. Exercise the boundary in native CTest and 32-bit Windows CI. Files: zlib/zutil.c, tests/zlib-allocation-test.c, tests/unittests/CMakeLists.txt, .github/workflows/test-win-latest.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5009227-6b49-4803-8153-63d8d94037e3
Express the same allocation checks without constant if conditions so the Windows 2022 compiler can enforce warnings as errors. Files: zlib/zutil.c, tests/zlib-allocation-test.c Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5009227-6b49-4803-8153-63d8d94037e3
Drain generation-scoped flushes before storage shutdown and retain batches when providers mutate their input, preventing stranded teardown and lost retries. Files: lib\offline\OfflineStorageHandler.cpp, lib\offline\OfflineStorageHandler.hpp, lib\pal\WorkerThread.cpp, tests\unittests\CMakeLists.txt, tests\unittests\OfflineStorageTests.cpp, tests\unittests\PalTests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7e2f450-c2c4-43c5-9fb1-05fa4f7d8e9e
File: tests/functests/MultipleLogManagersTests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5009227-6b49-4803-8153-63d8d94037e3
Reject unrepresentable compression bounds and handle allocation failure without exceptions. Decode size prefixes without alignment assumptions and reject truncated prefixes. Files changed: - lib/decoder/PayloadDecoder.cpp - tests/unittests/PayloadDecoderTests.cpp - tests/no-exceptions/no-exceptions-smoke.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5009227-6b49-4803-8153-63d8d94037e3
…to consolidate-1564
…nto consolidate-1564
…into consolidate-1564
… into consolidate-1564
Retain the SDK version and auth-token lock through exit-owner teardown. Honor Apple system SQLite/zlib even with vcpkg, and let independent embedded copies select a private Objective-C HTTP delegate name without changing the default. Files: CMakeLists.txt; cmake/MatsdkOptions.cmake; docs/embedding-with-cmake.md; lib/CMakeLists.txt; lib/api/AuthTokensController.cpp; lib/pal/PAL.cpp; tests/apple/embedding-options-tests.cmake; tests/apple/embedding-options/CMakeLists.txt; tests/embedding/CMakeLists.txt; tests/embedding/lifetime-tests.cmake; tests/embedding/lifetime-tests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5484aed9-9464-4bc8-9ca7-fd67954034ff (cherry picked from commit 66faca8)
The placement-new string avoided exit-time destruction but abandoned its heap buffer on unload: two real reload cycles leak 56 bytes under LSan. Return the compile-time literal through the internal const-char accessor instead, preserving late-worker safety without allocation or destruction. Keep the auth mutex and existing Apple embedding fixes unchanged. Files: - lib/pal/PAL.cpp, lib/pal/PAL.hpp: allocation-free internal version accessor. - tests/embedding/lifetime-tests.cpp: string-view value/address expectations. - tests/embedding/lifetime-tests.cmake: entry instrumentation and real DSO test. - tests/embedding/version-reload-fixture.cpp: embed the production SDK archive. - tests/embedding/version-reload-test.cpp: verify two actual unload cycles. - tests/embedding/CMakeLists.txt: opt-in Linux ASan/LSan coverage. - .github/workflows/test-embedding.yml: enforce sanitizer coverage in CI. Validation: Windows VS2026 and Linux GCC13 ASan/LSan embedding suites each pass all six tests. The old placement-new buffer leaks exactly 56 bytes; original destructible statics fail all three lifetime tests on both OSes. Formatting, existing misspell workflow and git diff --check pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5484aed9-9464-4bc8-9ca7-fd67954034ff (cherry picked from commit e630e2c)
Repeat 25% trims while the database remains oversized, stopping if resizing fails or makes no progress. Large flushes can otherwise leave the database above its limit and fail the iOS functional test. Files changed: lib/offline/OfflineStorage_SQLite.cpp; tests/unittests/OfflineStorageTests_SQLite.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2b4dcf34-18a6-4f77-9013-1db2fe20cc40 (cherry picked from commit 5f424de)
Restore upstream's cached BZip2 capability contract and pkg-config defaults instead of carrying SDK-unrelated dependency naming and configuration policy. Keep demonstrated gzip/ZIP runtime fixes, archive regressions, SDK shims, and the focused minizip include-directory, version, and large-file checks. Remove tests tied to the reverted packaging policies; preserve the original package consumers and shared/static archive tests. Files changed: - zlib/contrib/minizip/CMakeLists.txt - zlib/contrib/minizip/minizip.pc.txt - zlib/contrib/minizip/minizipConfig.cmake.in - zlib/contrib/minizip/test/CMakeLists.txt - zlib/contrib/minizip/test/find_package_test.cmake.in - zlib/contrib/minizip/test/pkg-config-test.cmake.in (removed) Validation: Windows minizip 11/11 and SDK embedding 6/6; Linux minizip 11/11 with BZip2 OFF and 11/11 ON, ASan/LSan embedding 6/6; existing misspell workflow and git diff --check. No remaining tests skipped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 976e8fb6-5cab-4bb8-955e-9eeb6f8d44d9 (cherry picked from commit 6fb4a2e)
Move the embedded-lifetime, Apple coexistence, SDK-version leak, batched-storage limit, and minizip packaging changes to microsoft#1564 so this PR only prepares the release version and can be reviewed and merged independently of the consolidated fixes. Files restored to main: .github/workflows/test-embedding.yml, CMakeLists.txt, cmake/MatsdkOptions.cmake, docs/embedding-with-cmake.md, lib/CMakeLists.txt, lib/api/AuthTokensController.cpp, lib/offline/OfflineStorage_SQLite.cpp, lib/pal/PAL.cpp, lib/pal/PAL.hpp, tests/embedding/CMakeLists.txt, tests/unittests/OfflineStorageTests_SQLite.cpp, zlib/contrib/minizip/*; removed tests/apple/embedding-options*, tests/embedding/lifetime-tests.*, tests/embedding/version-reload-*. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7f28ee63-9a2d-4346-8f00-4455e6bfc8a1
Use shell noclobber in tests/build-runner-tests.py so the mock processes cannot both take the same role when the external mkdir reports success twice. Resolve temporary paths before comparing the shell working directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 54c795bf-a207-409f-a052-7a84f6ac3854
There was a problem hiding this comment.
🟡 Changes recommended
Shutdown can complete after zero or partial persistence, preventing retries and allowing unpersisted records to be discarded on reinitialization.
8 open issues
Incomplete persistence lets shutdown discard cached records · New Windows CI test project does not enable /bigobj · New iOS/visionOS builds omit the unique Apple HTTP delegate name · New Trim can stop while the database remains over its size limit · New Absolute install directories are incorrectly prefixed in pkg-config · New Static pkg-config metadata omits or misorders dependencies · New pkg-config omits the minizip header directory · New Cached BZip2 setting can mismatch the installed package · New
What changed in this PR
Consolidates reliability and hardening fixes across the telemetry SDK’s lifecycle, offline storage, compression, and embedded-library support.
Changes:
- Synchronizes PAL lifecycle and strengthens storage shutdown, retries, and size enforcement.
- Hardens compression allocations and embedded SDK lifetimes; adds Apple coexistence options.
- Expands regression coverage and CI checks while simplifying vendored minizip packaging.
| File | Description |
|---|---|
| zlib/zutil.c | Guards allocation-size multiplication. |
| zlib/contrib/minizip/test/pkg-config-test.cmake.in | Removes custom pkg-config consumer fixture. |
| zlib/contrib/minizip/test/find_package_test.cmake.in | Simplifies package-consumer tests. |
| zlib/contrib/minizip/test/CMakeLists.txt | Removes pkg-config test registration. |
| zlib/contrib/minizip/minizipConfig.cmake.in | Restores cached BZip2 feature metadata. |
| zlib/contrib/minizip/minizip.pc.txt | Simplifies package flags and paths. |
| zlib/contrib/minizip/CMakeLists.txt | Trims custom packaging logic. |
| tests/zlib-allocation-test.c | Adds allocator boundary regression checks. |
| tests/unittests/PayloadDecoderTests.cpp | Tests compression bounds and size prefixes. |
| tests/unittests/PalTests.cpp | Covers concurrent lifecycle and logging generations. |
| tests/unittests/OfflineStorageTests.cpp | Covers flush cancellation, shutdown, and retries. |
| tests/unittests/OfflineStorageTests_SQLite.cpp | Tests repeated batch-size trimming. |
| tests/unittests/CMakeLists.txt | Adds allocation test and MSVC section-limit option. |
| tests/no-exceptions/no-exceptions-smoke.cpp | Extends PAL and compression smoke coverage. |
| tests/functests/MultipleLogManagersTests.cpp | Captures upload baseline before sending. |
| tests/functests/BasicFuncTests.cpp | Synchronizes PAL test accessors. |
| tests/embedding/version-reload-test.cpp | Checks version access across library reloads. |
| tests/embedding/version-reload-fixture.cpp | Exposes version accessor for reload tests. |
| tests/embedding/lifetime-tests.cpp | Tests late-worker version and mutex access. |
| tests/embedding/lifetime-tests.cmake | Wires lifetime instrumentation and reload fixtures. |
| tests/embedding/CMakeLists.txt | Adds sanitizer and Apple configuration tests. |
| tests/build-runner-tests.py | Stabilizes temporary paths and worker coordination. |
| tests/apple/embedding-options/CMakeLists.txt | Validates Apple dependency and delegate configuration. |
| tests/apple/embedding-options-tests.cmake | Runs the Apple configuration matrix. |
| lib/pal/WorkerThread.cpp | Cancels queued immediate tasks. |
| lib/pal/PAL.hpp | Declares synchronized lifecycle state and logging epochs. |
| lib/pal/PAL.cpp | Synchronizes initialization, publication, and teardown. |
| lib/offline/OfflineStorageHandler.hpp | Declares flush lifecycle machinery. |
| lib/offline/OfflineStorageHandler.cpp | Drains operations and retains failed batches. |
| lib/offline/OfflineStorage_SQLite.cpp | Repeats trimming for oversized batches. |
| lib/include/public/ICdsFactory.hpp | Adds integer-type header dependency. |
| lib/decoder/PayloadDecoder.cpp | Validates allocation bounds and reads prefixes safely. |
| lib/CMakeLists.txt | Applies private Apple delegate naming. |
| lib/api/AuthTokensController.cpp | Preserves auth mutex for late workers. |
| docs/embedding-with-cmake.md | Documents Apple embedding coexistence settings. |
| CMakeLists.txt | Uses Apple system libraries under vcpkg. |
| cmake/MatsdkOptions.cmake | Adds validated delegate-class option. |
| .github/workflows/test-win-latest.yml | Runs Win32 allocation-bound checks. |
| .github/workflows/test-embedding.yml | Adds Linux sanitizer lifetime coverage. |
Review effort: Balanced
The SDK now targets the Windows 10 API floor, so GetSystemTimePreciseAsFileTime is always available. The runtime kernel32 lookup and GetSystemTimeAsFileTime fallback only preserved Windows 7 compatibility, which no longer applies. Files changed: - lib/pal/PAL.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd197032-9b52-4cdc-9a3b-d23c8ec90596
Keep a failed final storage flush retryable on zero, short batch, or
per-record writes. Preserve the generation and owner until shutdown can
complete, and surface failure across C and JNI without leaking C++
exceptions. Cover retry and invalid paths in the unit and functional tests.
lib/offline/OfflineStorageHandler.{cpp,hpp}; lib/api/LogManagerImpl.{cpp,hpp};
lib/api/{LogManagerFactory.cpp,capi.cpp}; lib/include/public/LogManagerBase.hpp;
lib/jni/LogManager_jni.cpp; tests/unittests/{LogManagerImplTests,OfflineStorageTests}.cpp;
tests/functests/APITest.cpp.
Keep trimming when committed deletes make progress without shrinking the
SQLite file yet. Cover the packed-small-records case at the batch limit.
lib/offline/OfflineStorage_SQLite.{cpp,hpp}; tests/unittests/OfflineStorageTests_SQLite.cpp.
Apply /bigobj to OfflineStorageTests.cpp in the native Windows CI project
without replacing inherited options. Apply the configured delegate name
whenever the Apple HTTP source is selected, including HTTP-off mobile
builds. Extend the configure matrix to guard this case.
tests/unittests/UnitTests.vcxproj; lib/CMakeLists.txt;
tests/apple/{embedding-options-tests.cmake,embedding-options/CMakeLists.txt}.
Restore standalone minizip packaging to the PR base rather than maintain
an SDK-unneeded change to absolute paths, static dependency order, include
flags, and package-derived BZip2 state. Keep the vendor sources that
Windows and the zlib clean target still use.
zlib/contrib/minizip/{CMakeLists.txt,minizip.pc.txt,minizipConfig.cmake.in};
zlib/contrib/minizip/test/{CMakeLists.txt,find_package_test.cmake.in,pkg-config-test.cmake.in}.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2dc9129f-15f0-482c-a1ea-d48d05909daf
There was a problem hiding this comment.
🟡 Changes recommended
The last-owner release can delete the manager despite a failed final flush, losing retained records while reporting success across multiple release paths.
1 open issue
8 resolved since last review
Windows CI test project does not enable /bigobj Incomplete persistence lets shutdown discard cached records Cached BZip2 setting can mismatch the installed package pkg-config omits the minizip header directory Static pkg-config metadata omits or misorders dependencies Absolute install directories are incorrectly prefixed in pkg-config Trim can stop while the database remains over its size limit iOS/visionOS builds omit the unique Apple HTTP delegate name
Review effort: Balanced
A last owner can release without explicitly flushing. Complete teardown
before removing either the lease or the registered manager. Keep the
manager retryable when a provider refuses a write and report failure if
pipeline shutdown throws before storage is reached.
Reserve teardown before callbacks and avoid holding the factory lock
while they run. Reject reentrant final release or acquisition of the
reserved manager. A nonfinal shared release still only drops its lease.
Use the shutdown result at C and JNI boundaries and roll back an open
that cannot acquire a manager. Verify exclusive, host-specific shared,
and name-only shared release, including retry of the exact failed record.
Files:
lib/api/LogManagerFactory.{cpp,hpp}
lib/api/LogManagerImpl.{cpp,hpp}
lib/api/capi.cpp
lib/include/public/LogManagerBase.hpp
lib/jni/LogManager_jni.cpp
tests/unittests/LogManagerImplTests.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2dc9129f-15f0-482c-a1ea-d48d05909daf
There was a problem hiding this comment.
🟡 Changes recommended
Critical lifecycle bugs allow acquisitions of a partially torn-down manager that silently drops events and release the wrong client's lease, potentially retaining a shared C API handle indefinitely.
2 open issues
1 resolved since last review
Review effort: Balanced
A failed teardown has already retired loggers. Keep the manager in a
retiring state that admits an explicit retry but never accepts another
lease. Test acquisition rejection both during and after failure.
Release a C handle with its own lease configuration, not the shared
manager's creator configuration. Retain the creator's configuration for
the manager lifetime so closing the creator first leaves its guests
working. Reserve handles before acquiring, roll back a failed open, and
reject distinct configs that would reuse a lease in the same pool.
Test both close orders, wildcard rehoming, and survivor event intake.
Files:
lib/api/LogManagerFactory.{cpp,hpp}
lib/api/LogManagerImpl.{cpp,hpp}
lib/api/capi.cpp
tests/functests/APITest.cpp
tests/unittests/LogManagerImplTests.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2dc9129f-15f0-482c-a1ea-d48d05909daf
An exact duplicate is idempotent only while its manager still accepts
leases. Check that the original manager is registered and open before
returning a duplicate handle, without nesting the handle and factory
locks. Keep a failed close's original handle usable for retry.
Cover a real failed final flush, rejection of a duplicate open, and
successful cleanup, retry, and reopen on Windows and Linux.
Files:
lib/api/LogManagerFactory.{cpp,hpp}
lib/api/capi.cpp
tests/functests/APITest.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2dc9129f-15f0-482c-a1ea-d48d05909daf
There was a problem hiding this comment.
🟡 Changes recommended
After failed teardown, GetLogger() can return a logger for a paused manager, causing subsequent events to be silently discarded unless it rejects managers whose teardown has started.
1 open issue
1 resolved since last review
Review effort: Balanced
A failed teardown leaves the manager available for retry but cannot accept events. Reject logger acquisition before and after normalization when teardown has started. Verify that singleton reinitialization and C API logging fail rather than silently accepting work during retirement. Files: lib/api/LogManagerImpl.cpp tests/functests/APITest.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2dc9129f-15f0-482c-a1ea-d48d05909daf
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because an unpublished compatibility finding shows the test matrix requires CMake 3.19 and fails CTest on supported versions 3.15–3.18.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
The embedding suite advertises CMake 3.15, so its Apple CTest must not fail before the matrix runs on versions 3.15 through 3.18. Keep the matrix's existing 3.19 policy ceiling on newer CMake. Verified the prior failure and all 19 passing cases on CMake 3.15.7, and reran the matrix with current CMake on Windows and WSL. Files changed: - tests/apple/embedding-options-tests.cmake: align the driver minimum. - tests/apple/embedding-options/CMakeLists.txt: align the fixture minimum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2dc9129f-15f0-482c-a1ea-d48d05909daf
There was a problem hiding this comment.
🔵 Needs a closer look
The cross-component lifecycle and embedding changes need platform-owner review and runtime validation, as Apple coverage is configure-only and Android shutdown/retry teardown is compile-only.
No open issues 🎉
Review effort: Balanced


Summary
Consolidates several independent reliability and hardening fixes into one PR to reduce review overhead. See the linked PRs for the original rationale and per-change validation. The review follow-up refines the changes below.
GetSystemTimePreciseAsFileTimedirectly now that the Windows 10 API floor guarantees it; drop the Windows 7 runtime lookup and fallback.zcallocallocation products (CodeQLcpp/integer-multiplication-cast-to-long); Win32 regression test./bigobjforOfflineStorageTests.cppin both CMake and native Windows CI.MATSDK_APPLE_HTTP_DELEGATE_CLASSwhenever the Apple HTTP source is built; lifetime, unload/reload (ASan/LSan), and Apple config matrix tests.storageFileSizeDoesntExceedConfiguredSizefailure seen on #1567).#1560 now only bumps the release version.
The standalone minizip packaging changes were reverted.
zlib/contribmatches the PR base; native Windows zlib still uses minizip I/O sources.Validation (review follow-up)
No skips or disabled tests in these runs. The native Windows test sources compiled, including the
/bigobjchange. The exact last-lease retry tests also passed with C++ exceptions disabled, including retry of busy C API opens. The WSL no-exception smoke, Android JNI/C API compile checks, CI-pinned misspell, andgit diff --checkpassed. The unfiltered suites were run after the final SDK code change. The subsequent Apple CMake-only fix passed all 19 configurations on Windows and WSL, including CTest with CMake 3.15.7 on WSL (the prior 3.19 requirement reproduced the failure there). The Apple matrix is configure-only; Android runtime was not tested.Validation (combined branch, before review follow-up)
UnitTests(unfiltered)FuncTests(unfiltered)tests/embeddingCTesttests/no-exceptionsCTestUnitTests: 769 passed, 0 disabled; zlib allocation)FuncTests(unfiltered)tests/embeddingCTesttests/no-exceptionsCTestBuilds were warning-free on both platforms. The repository misspell workflow (CI semantics) and
git diff --checkpass. No tests were filtered or skipped.Known pre-existing
mainfailures (Build runner contracts,Public header gate) are unrelated to this PR.